﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace BaseWindow
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            //全局监听异常
            base.OnStartup(e);
            this.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
            
        }

        void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            HandyControl.Tools.ConfigHelper.Instance.SetLang("zh-CN");
            //提示
            HandyControl.Controls.MessageBox.Error(e.Exception.Message);
            //日志
            BaseTool.LogHelper.WriteError("未知异常：" + e.Exception.Message, e.Exception);
            //已处理
            e.Handled = true;
        }
    }
}
